// test JSON
var text = '{ "employees" : [' +
    '{ "firstName":"John" , "lastName":"Doe" },' +
    '{ "firstName":"Anna" , "lastName":"Smith" },' +
    '{ "firstName":"Peter" , "lastName":"Jones" } ]}';
var obj = JSON.parse(text);
console.log(typeof obj)
console.log(obj.employees[0].firstName)

console.log(JSON.stringify(obj))


var person={fname:"Bill",lname:"Gates",age:56};//对象赋值的时候字段名称不需要""
console.log(JSON.stringify(person))
var str = '{"fname":"Bill","lname":"Gates","age":56}'
person = JSON.parse(str) //解析的时候要求字段名称必须有 ""
console.log(person.age)

person = eval('('+str+')') //eval解析的时候 字符串要有()包括才能解析
					//必须把文本包围在括号中，这样才能避免语法错误
console.log(person.age)


